//
//  BmCacheManager.h
//  BimaMatrix
//
//  Created by Aimeow on 4/14/15.
//  Copyright (c) 2015 Aimeow. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface BmCacheManager : NSObject

DECLARE_SINGLETON(BmCacheManager)

// 缓存的路径
+ (NSString *)dbPath;

/**
 @param cache <NSCoding> 带缓存数据
 key 缓存时的key
 */
- (void)setCache:(id<NSCoding>)cache forKey:(NSString *)key;
/**
 @param cache <NSCoding> 带缓存数据
 key 缓存时的key
 duration 缓存过期时间
 */
- (void)setCache:(id<NSCoding>)cache forKey:(NSString *)key duration:(NSInteger)duration;

/**
 @param key 缓存数据时的key
 @return    缓存的数据
 */
- (void)cacheForKey:(NSString *)key success:( void (^) (id data))success;

/**
 @return 是否存在缓存
 */
- (BOOL)containsCache:(NSString *)key;

//根据key删除缓存
- (void)removeCache:(NSString *)key;

- (void)clearCache;

@end
